package com.hmall.user.controller;

import cn.hutool.core.lang.Assert;
import com.hmall.common.domain.R;
import com.hmall.user.domain.dto.AddPermissionDTO;
import com.hmall.user.service.SysPermissionsService;
import com.hmall.user.service.SysRolePermissionsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*********************************************************
 ** 权限controller
 ** <br><br>
 ** @ClassName: PermissionController
 ** @author: yangfeng
 ** @date: 2024/12/25 15:25
 ** @version: 1.0.0
 *********************************************************/
@RestController
@RequestMapping("/permission")
@Slf4j
@RequiredArgsConstructor
public class PermissionController {
    private final SysPermissionsService sysPermissionsService;

    private final SysRolePermissionsService sysRolePermissionsService;
    /**
     * 新增权限
     * @param dto
     * @Return: com.hmall.common.domain.R<java.lang.Boolean>
     * @author: yangfeng
     * @date: 2024/12/25 15:36
     **/
    @PostMapping(value = "/add",name = "新增权限")
    public R<Boolean> add(@RequestBody AddPermissionDTO dto){
        Assert.notNull(dto,"新增权限参数不可为空");
        Assert.notBlank(dto.getRequestMethod(),"请求方法不可为空");
        Assert.notBlank(dto.getRequestPath(),"请求路径不可为空");
        return R.ok(sysPermissionsService.addPermission(dto));
    }
}
